package com.gs.SynPatrolRep.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.gs.SynPatrolRep.R;
import com.gs.SynPatrolRep.constant.AllConstants;
import com.gs.SynPatrolRep.util.AppUtil;
import com.gs.SynPatrolRep.util.SPUtil;
import com.gs.SynPatrolRep.util.WindowUtil;

public class WelcomeActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        WindowUtil.getInstance().setWindowDecorView(this);
        TextView tvVersion = findViewById(R.id.tv_version);
        tvVersion.setText(AppUtil.getInstance().getVersion());
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(3000);
                    if (TextUtils.isEmpty(SPUtil.getInstance().getString(AllConstants.TOKEN))) {
                        startActivity(new Intent(WelcomeActivity.this,LoginActivity.class));
                    }else {
                        startActivity(new Intent(WelcomeActivity.this, MainActivity.class));
                    }
                    finish();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();
    }
}